<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="div1"></div>
		<button onclick="p1()">开启setInterval</button>
		<button onclick="p4()">停止setInterval</button>
		
		<button onclick="p5()">开启setTimeout</button>
		<button onclick="p7()">停止setTimeout</button>
		
		<script>
			var p3;
			var p6;
			//setInterval() 方法
			function p1(){
				p3 = setInterval(function(){
					console.log("Hello");
				},3000)
			}
			//显示当前时间
			function p2(){
				var d =Date();
				var t = d.toLocaleUpperCase();
				document.getElementById("div1").innerHTML = t;
			}
			
			setInterval(function(){p2()},1000);
			
			//停止
			function p4(){
				clearInterval(p3);
			}
			
			//setTimeout() 方法
			function p5(){
				p6 = setTimeout(function(){
					alert("Hello");
				},3000)
			}
			
			//停止setTimeout
			function p7(){
				clearTimeout(p6);
			}
		</script>
	</body>
</html>